<?php
session_start();
 require_once 'data/databaseconnection.php';
	

if(!user_loggedin())
{
header('Location:index.php');
}
else{
$oldpassword=$_POST['oldpassword'];
$newpassword=$_POST['newpassword'];
$confirmpassword=$_POST['confirmpassword'];
if($_SESSION['password']==$oldpassword)
{
	if($newpassword==$confirmpassword)
	{
		$pl= strlen($newpassword);
		if($pl<8)
		{
		header("Location:Changepassword.php?err2=Password's length must be atleast eight !");
		}
		else
		{
		
		$csvLine =chunk_split($newpassword,1,".");
		$items = explode(".", $csvLine); 
		//if(check($items,$pl)) echo "correct int";
		$p=false;
		$i=0;
						while((!$p) && i<$pl)
									{
													$a=$items[i];
													if(is_int($a))  $p=true;
															else $i++;
																			}
											if($p) echo "Correct";
											else echo "incot";
												
												
												
												
												
												
												
		
		}
	}
	else
	{
	header("Location:Changepassword.php?err2=Please Confirm your Password!");
	}
}
else
{
header("Location:Changepassword.php?err2=Incorrect old Password!");

}
}
/*function check($items,$pl)
{
$p=false;
$i=0
while((!$p) && i<$pl)
{
$a=$items[i];
if(is_int($a)) return true;
else $i++;
}
return $p;
}*/
?>
